package me.hl.guava.collect;

import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Set;


/**
 * Created by haoliang on 2016/7/31.
 */
public class MultisetTest {
    private static Logger logger = LoggerFactory.getLogger(MultisetTest.class);


    @Test
    public void multisetTest() {
        Multiset<String> multiset = HashMultiset.create();

        multiset.add("111");
        multiset.add("111");
        multiset.add("222");
        logger.info("111 elements count is {}", multiset.count("111"));
        logger.info("222 elements count is {}", multiset.count("222"));
        logger.info("333 elements count is {}", multiset.count("333"));
        logger.info("all elements conut is {}", multiset.size());

        Set<String> set;
        set = multiset.elementSet();
        set.forEach((a) -> logger.info("{}", a));

    }
}
